//
//  AddStoreServerViewController.m
//  com.modada.new
//
//  Created by ferver7 on 2019/6/4.
//  Copyright © 2019 ferver7. All rights reserved.
//

#import "AddStoreServerViewController.h"

@interface AddStoreServerViewController ()
@property (weak, nonatomic) IBOutlet PPTextfield *namePP;
@property (weak, nonatomic) IBOutlet PPTextfield *pricePP;
@property (weak, nonatomic) IBOutlet PPTextfield *toPricePP;

@end

@implementation AddStoreServerViewController
-(void)rightAction
{
    if (self.namePP.text.length < 1) {
         [AxcUI_Toast AxcUI_showCenterWithText:@"请输入项目名字"];
        return;
    }
    if (self.pricePP.text.length < 1) {
        [AxcUI_Toast AxcUI_showCenterWithText:@"请输入价格"];
        return;
    }
    if (self.toPricePP.text.length < 1) {
        [AxcUI_Toast AxcUI_showCenterWithText:@"请输入上门服务费"];
        return;
    }
    NSMutableDictionary * requestInfo = [[NSMutableDictionary alloc]init];
    if (self.infoDic) {
        setDickeyobj(requestInfo, self.infoDic[@"serviceId"], @"serviceId");
    }
    setDickeyobj(requestInfo, self.namePP.text, @"project");
    setDickeyobj(requestInfo, self.pricePP.text, @"price");
    setDickeyobj(requestInfo, self.toPricePP.text, @"servicePrice");
    [PPNetworkHelper POST:app_person_myStore_addorUpdateProject parameters:requestInfo success:^(id responseObject) {
        if (YJPPSUCCESS(responseObject)) {
            if (self.infoDic) {
                 [AxcUI_Toast AxcUI_showCenterWithText:@"更新成功"];
            }else{
                 [AxcUI_Toast AxcUI_showCenterWithText:@"新增成功"];
            }
           
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            
        }
    } failure:^(NSError *error) {
        
    } showLoading:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    mNavitationTitle(@"新增");
    [self customNavigationItems];
    [self addRightBarButtonItemWithTitle:@"保存" action:@selector(rightAction)];
    
    self.namePP.layer.masksToBounds = YES;
    self.namePP.layer.cornerRadius = 5;
    self.namePP.layer.borderWidth = 1;
    self.namePP.layer.borderColor = [[UIColor AxcUI_colorWithHexCode:@"#676767"] CGColor];
    
    self.pricePP.layer.masksToBounds = YES;
    self.pricePP.layer.cornerRadius = 5;
    self.pricePP.layer.borderWidth = 1;
    self.pricePP.layer.borderColor = [[UIColor AxcUI_colorWithHexCode:@"#676767"] CGColor];
    
    self.toPricePP.layer.masksToBounds = YES;
    self.toPricePP.layer.cornerRadius = 5;
    self.toPricePP.layer.borderWidth = 1;
    self.toPricePP.layer.borderColor = [[UIColor AxcUI_colorWithHexCode:@"#676767"] CGColor];
    
    self.pricePP.isPrice = YES;
    self.pricePP.maxTextLength = 8;
    self.toPricePP.isPrice = YES;
    self.pricePP.maxTextLength = 8;
    
    if (self.infoDic) {
        self.namePP.text = self.infoDic[@"project"];
        self.pricePP.text = [NSString stringWithFormat:@"%@",self.infoDic[@"price"]];
        self.toPricePP.text = [NSString stringWithFormat:@"%@",self.infoDic[@"servicePrice"]];
    }
}


@end
